"""
内容:再首页点击搜索后,选择展示方式,图文,文本,大图三种类型
"""
#引入模块
from ECshop.common.base import Base,create_browser_op
import time

#创建一个类
class PageShowChoice(Base):
    #定义属性
    url = "http://localhost:8080/ecshop/search.php?encode=YTozOntzOjg6ImtleXdvcmRzIjtzOjA6IiI7czoxMDoiaW1hZ2VGaWVsZCI7czo2OiLmkJzntKIiO3M6MTg6InNlYXJjaF9lbmNvZGVfdGltZSI7aToxNjU3MDk0MzY3O30="
    search_button = ("name", "imageField")
    image_text=("css selector","img[src='themes/default/images/display_mode_list.gif']")
    image=("css selector","img[src='themes/default/images/display_mode_grid.gif']")
    text=("css selector","img[src='themes/default/images/display_mode_text.gif']")
    box=("css selector","form[id='compareForm']>div")
    name='class'
    # print(p1.find_element_by_css_selector("form[id='compareForm']>div").get_attribute('class'))

    #定义方法
    #进入网页
    def page_show_choice_open_web(self):
        self.base_open_web(self.url)

    #点击图文方式
    def page_show_choice_click_image_text(self):
        self.base_click(self.image_text)

    #点击大图方式
    def page_show_choice_click_image(self):
        self.base_click(self.image)

    #点击文本方式
    def page_show_choice_click_text(self):
        self.base_click(self.text)

    #获取元素值
    def page_show_choice_get_value(self):
        return self.base_get_value(self.box,self.name)

    #关闭
    def page_show_choice_quit(self):
        self.base_quit()
if __name__ == '__main__':
        pc1=PageShowChoice(create_browser_op(r'C:\Users\86184\AppData\Local\Google\Chrome\User Data'))
        # time.sleep(1)
        pc1.page_show_choice_open_web()
        # time.sleep(1)
        pc1.page_show_choice_click_image_text()
        # time.sleep(3)
        pc1.page_show_choice_click_image()
        # time.sleep(3)
        pc1.page_show_choice_click_text()
        print(pc1.page_show_choice_get_value())
        # time.sleep(3)
        pc1.page_show_choice_quit()